from odoo import fields, models


class WorkflowItem(models.Model):
    _inherit = 'sb.workflow.item'

    def skip_view(self):
        if self.sb_workflow_id.workflow_type == 'account_in':
            move_id = self.env['account.move'].search([('s_workflow_id', '=', self.sb_workflow_id.id)], limit=1)
            return {
                'name': 'Invoice',
                'type': 'ir.actions.act_window',
                'res_model': 'account.move',
                'view_mode': 'form',
                'res_id': move_id.id,
                'views': [(self.env.ref('purchase_account_inherit.s_account_move_form_workflow_view').id, 'form')],
                'target': 'new',
            }
        else:
            return super().skip_view()